import QtQuick 2.12
import QtQuick.Window 2.12

Image {
    id: root
    source: "assets/background.png"

    property int padding: 40
    property int duration: 4000
    property bool running: false

    MouseArea {
        anchors.fill: parent
        onClicked: root.running = true
    }

    Image {
        id: box
        x: root.padding
        y: (root.height - height) / 2
        source: "assets/box_green.png"
        antialiasing: true //可以减少锯齿的样子
        NumberAnimation on x {
            to: root.width - box.width - root.padding
            duration: root.duration //延时4000
            running: root.running
        }
        RotationAnimation on rotation {
            to: 360
            duration: root.duration
            running: root.running
        }
    }
    MouseArea {
        id: myArea
        anchors.fill: box
        onClicked: {
            root.running = false
            box.x = root.padding
            box.y = (root.height - height) / 2
            box.rotation = 0
        }
    }
}
